package com.timous.数组;

/**
 * https://leetcode-cn.com/problems/reorganize-string/
 */
public class _767_重构字符串 {

    public String reorganizeString(String S) {
        if (S.length() < 2){
            return S;
        }
        char[] chars = S.toCharArray();
        int[] arr = new int[26];
        for (int i : arr) {
            arr[i] = 0;
        }
        for (char aChar : chars) {
            arr[aChar - 'a'] ++ ;
            if (arr[aChar - 'a'] > S.length()/2){
                return "";
            }
        }


        return "";
    }

}
